package com.fly.autogetcode;

import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;

/**
 * Created by weifeiyang on 2015/9/16 0016.
 * <p/>
 * 计时器
 */
public class TimeCountUtil extends CountDownTimer {

    private Button checking;

    public TimeCountUtil(long millisInFuture, long countDownInterval, View view) {
        super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔
        checking = (Button) view;
    }

    @Override
    public void onFinish() {//计时完毕时触发
        checking.setText("重新验证");
        checking.setClickable(true);
    }

    @Override
    public void onTick(long millisUntilFinished) {//计时过程显示
        checking.setClickable(false);
        checking.setText(millisUntilFinished / 1000 + "s");
    }
}
